package ObjectOrientedTest4;

public class PhoneTest {
    public static void main(String[] args) {
        //1.创建一个数组
        Phone[] arr=new Phone[3];

        //2.创建手机对象
        Phone p1=new Phone("xiaomi",1999,"write");
        Phone p2=new Phone("huawei",4999,"blue");
        Phone p3=new Phone("meizu",3999,"red");

        //3.把手机对象添加到数组中
        arr[0]=p1;
        arr[1]=p2;
        arr[2]=p3;

        //4.获取三部手机的价格
        int sum=0;
        for (int i = 0; i < arr.length; i++) {
            Phone phone=arr[i];
            sum=sum+phone.getPrice();
        }

        //求平局数
//        int avg=sum/arr.length;
        double avg=sum*1.0/arr.length;
        System.out.println(avg);
    }
}
